package com.hbgjq.security.config;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;

/**
 * @author :Gjq
 * @date :2021/1/6
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MyGrantedAuthority implements GrantedAuthority {

    private String name;
    private String code;

    @Override
    public String getAuthority() {
        return this.code;
    }

    @Override
    public boolean equals(Object o) {
        if (o instanceof MyGrantedAuthority){
            MyGrantedAuthority myGrantedAuthority = (MyGrantedAuthority) o;
            if (myGrantedAuthority.code.equals(code)) {
                return true;
            }
        }
        return false;
    }
}
